package com.baosight.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class HelloService {

	
	@Autowired
    RestTemplate restTemplate;

	@HystrixCommand(fallbackMethod = "hiError")
    public String hiService() {
        return restTemplate.getForObject("http://springboot-eureka-clent/ribbon",String.class);
    }
	
	public List getInfo( String id) {
		return restTemplate.getForObject("http://springboot-eureka-clent/{1}", List.class, id);
	}
	
	public List home(){
		return restTemplate.getForObject("http://springboot-eureka-clent/list", List.class);
	}
	
	 public String hiError() {
	        return "hi,sorry,error!";
	    }
}
